package cn.edu.zafu.bigdata.lwg;

public abstract class Shape {
    public abstract double area();

    public abstract double perimeter();

    public final void display() {
        System.out.println("Shape: " + this.getClass().getSimpleName());
        System.out.println("Area: " + area());
        System.out.println("Perimeter: " + perimeter());
    }
}

class Circle extends Shape {
    private double radius;

    public Circle(double radius) {
        this.radius = radius;
    }

    @Override
    public double area() {
        return Math.PI * radius * radius;
    }

    @Override
    public double perimeter() {
        return 2 * Math.PI * radius;
    }
}

class Rectangle extends Shape {
    private double length;
    private double width;

    public Rectangle(double length, double width) {
        this.length = length;
        this.width = width;
    }

    @Override
    public double area() {
        return length * width;
    }

    @Override
    public double perimeter() {
        return 2 * (length + width);
    }
}

class TestShape {
    public static void main(String[] args) {
        Shape circle = new Circle(5.0);
        Shape rectangle = new Rectangle(3.0, 4.0);

        circle.display();
        rectangle.display();

        VariableTest variableTest = new VariableTest();
        variableTest.modifyValue();
    }
}

final class FinalClass {
}

class ParentClass {
    public final void finalMethod() {
        System.out.println("ParentClass's final method");
    }
}


class VariableTest {
    public final int value = 10;

    public void modifyValue() {
        System.out.println("Final variable value: " + value);
    }
}